/*	Copyright 2007 - Xavier Baro (xbaro@cvc.uab.cat)

	This file is part of eapmlib.

    Eapmlib is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or any 
	later version.

    Eapmlib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CLASSIFIER_H__
#define __CLASSIFIER_H__

#include "EvolutiveLib.h"
#include "Data.h"
#include "Chromosome.h"
//#include "cv.h"
#include <fstream>
#include <iostream>

using namespace std;
namespace Evolutive {

	class EVOLUTIVELIB_API CClassifier
	{
		//! Methods
	public:
		//! Default constructor		
		CClassifier(void);

		//! Default destructor
		virtual ~CClassifier(void);		

		//! Returns the class name
		virtual string GetClassNameID(void) = 0;

		//! Classify a given data
		virtual double Apply(CData *InputData) = 0;

		//! Sets the feature parameters from a chromosome
		virtual void SetFeatureParameters(CChromosome *C) = 0;

		//! Returns the feature parameters that defines the classifier
		virtual void GetFeatureParameters(int &NumParameters,double **Parameters) = 0;

		//! Verify if a certain Chromosome is a valid solution
		virtual bool IsValid(CChromosome *C);

		//! Set filter parameters
		void SetFilter(bool Actived);
		void SetFilter(bool Actived, CvSize ImageSize,bool UseColor);

		//! Returns the window size
		CvSize GetSize(void);

		//! Sets the window size
		void SetSize(int Width, int Height);

		//! Load a classifier from a file
		void Load(string FileName);

		//! Save a classifier to a file
		void Save(string FileName);

		//! Save or recover the data to/from a file
		virtual void Serialize(std::fstream &fs,bool Saving);
								
	protected:		
					
		//! Attributes
	protected:		
		//! Images size
		CvSize m_ImageSize;

		//! Indicates when the images are used in color or in gray scale
		bool m_UseColor;

		//! Active filter. Indicates if the input data must be Checked
		bool m_FilterActive;
	};	
}

#endif // __CLASSIFIER_H__
